<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/socket.io/socket.io.js" type="text/javascript"></script>
    <script type="text/javascript">
        var socket = io.connect('http://127.0.0.1:3000');
        socket.on('message', function (data) {
            alert(data.msg);
        });
        function sendMsg() {
            var value = document.getElementById('msg').value;
            socket.emit('asura', {value: value});
        }
        function register() {
            //给服务器传递一个匿名回调函数
            socket.emit('register', 0, function (data) {
                alert("服务器返回" + data);
            });
        }
    </script>
</head>
<body>
输入message:<input type="text" id="msg"/><br>
<button onclick="sendMsg()">send a message</button>
<br>
<button onclick="register()">register</button>
<br>
</body>
</html>